package com.franklin.ideaplugin.maphelper.col.operation.impl.collection.deque;

import com.franklin.ideaplugin.maphelper.col.method.IColInsertMethod;
import com.franklin.ideaplugin.maphelper.col.method.IColQueryMethod;
import com.franklin.ideaplugin.maphelper.col.method.impl.ColInsertMethodImpl;
import com.franklin.ideaplugin.maphelper.col.method.impl.DefaultColQueryMethod;
import com.franklin.ideaplugin.maphelper.col.operation.impl.collection.queue.BlockingQueueReadWriteOperation;

import java.util.Set;
import java.util.concurrent.BlockingDeque;

/**
 * 双向阻塞队列操作
 *
 * @author Ye Junhui
 * @since 2024/3/11
 */
public class BlockingDequeReadWriteOperation extends DequeReadWriteOperation {

    /**
     * 多继承
     */
    private final static BlockingQueueReadWriteOperation blockingQueueReadWriteOperation = new BlockingQueueReadWriteOperation();

    @Override
    public String getClassQualifiedName() {
        return BlockingDeque.class.getName();
    }

    @Override
    public Set<IColInsertMethod> getInsertMethods() {
        Set<IColInsertMethod> blockingQueueReadWriteOperationInsertMethods = blockingQueueReadWriteOperation.getInsertMethods();
        Set<IColInsertMethod> insertMethods = super.getInsertMethods();
        insertMethods.addAll(blockingQueueReadWriteOperationInsertMethods);
        insertMethods.add(new ColInsertMethodImpl("addFirst", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("addLast", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("offerFirst", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("offerLast", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("putFirst", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("putLast", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("add", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("offer", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("put", 1, 0));
        insertMethods.add(new ColInsertMethodImpl("offer", 3, 0));
        insertMethods.add(new ColInsertMethodImpl("push", 1, 0));
        return insertMethods;
    }

    @Override
    public Set<IColQueryMethod> getQueryMethods() {
        Set<IColQueryMethod> blockingQueueReadWriteOperationQueryMethods = blockingQueueReadWriteOperation.getQueryMethods();
        Set<IColQueryMethod> queryMethods = super.getQueryMethods();
        queryMethods.addAll(blockingQueueReadWriteOperationQueryMethods);
        queryMethods.add(new DefaultColQueryMethod("takeFirst", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("takeLast", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("pollFirst", 2, -1));
        queryMethods.add(new DefaultColQueryMethod("pollLast", 2, -1));
        queryMethods.add(new DefaultColQueryMethod("remove", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("poll", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("take", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("poll", 2, -1));
        queryMethods.add(new DefaultColQueryMethod("element", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("peek", 0, -1));
        queryMethods.add(new DefaultColQueryMethod("element", 0, 0));
        queryMethods.add(new DefaultColQueryMethod("peek", 0, 0));
        return queryMethods;
    }
}
